package cn.edu.scau.cmi.zhuangjunsheng.comprehensiveExperiment;

import java.io.IOException;
import java.util.Objects;

import cn.edu.scau.cmi.zhuangjunsheng.Client.AdapterClient;
import cn.edu.scau.cmi.zhuangjunsheng.Client.ComprehensiveClient;
import cn.edu.scau.cmi.zhuangjunsheng.comprehension.domain.Student;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class UI {
	
	
	@FXML
	private Button singleton;
	@FXML
	private Button multition;
	@FXML
	private Button interProgramming;
	@FXML
	private Button simpleFactory;
	@FXML
	private Button factory;
	@FXML
	private Button abstractFactory;
	@FXML
	private Button adapterOfClass;
	@FXML
	private Button adapterOfObject;
	@FXML
	private Button safeComposite;
	@FXML
	private Button consistentComposite;
	
	@FXML
	public void onSingleton(ActionEvent av) throws Exception {
        
        try {
        	
        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/SingletonUI.fxml"));
        	Scene scene = new Scene(parent);
            Stage primaryStage = new Stage();
            primaryStage.setScene(scene);
            primaryStage.show();
           
        } catch (Exception e) {
            e.printStackTrace();
        }
        
	}
	
	@FXML
	public void onMultition(ActionEvent av) throws Exception {
		
		try {
        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/MultitonUI.fxml"));
        	Scene scene = new Scene(parent);
            Stage primaryStage = new Stage();
            primaryStage.setScene(scene);
            primaryStage.show();
           
        } catch (Exception e) {
            e.printStackTrace();
        }
		
	}
	
	@FXML
	public void onInterProgramming(ActionEvent av) throws Exception {
		
		try {
        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/InterUI.fxml"));
        	Scene scene = new Scene(parent);
            Stage primaryStage = new Stage();
            primaryStage.setScene(scene);
            primaryStage.show();
           
        } catch (Exception e) {
            e.printStackTrace();
        }
		
	}
	
	@FXML
	public void onSimpleFactory(ActionEvent av) throws Exception {
		
		try {
        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/SimpleFactoryUI.fxml"));
        	Scene scene = new Scene(parent);
            Stage primaryStage = new Stage();
            primaryStage.setScene(scene);
            primaryStage.show();
           
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	
	@FXML
	public void onFactory(ActionEvent av) throws Exception {
		
		try {
        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/FactoryUI.fxml"));
        	Scene scene = new Scene(parent);
            Stage primaryStage = new Stage();
            primaryStage.setScene(scene);
            primaryStage.show();
           
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	
	@FXML
	public void onAbstractFactory(ActionEvent av) throws Exception {
		
		try {
        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/AbstractFactoryUI.fxml"));
        	Scene scene = new Scene(parent);
            Stage primaryStage = new Stage();
            primaryStage.setScene(scene);
            primaryStage.show();
           
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	
	@FXML
	public void onAdapterOfClass(ActionEvent av) throws Exception {
		
		try {
			/*
        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/AdapterOfClassUI.fxml"));
        	Scene scene = new Scene(parent);
            Stage primaryStage = new Stage();
            primaryStage.setScene(scene);
            primaryStage.show();
            */
			AdapterClient adapterClient = new AdapterClient();
			Stage primaryStage = new Stage();
			adapterClient.start(primaryStage);
           
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	
	@FXML
	public void onAdapterOfObject(ActionEvent av) throws Exception {
		
		try {
//        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/AdapterOfObjectUI.fxml"));
//        	Scene scene = new Scene(parent);
//            Stage primaryStage = new Stage();
//            primaryStage.setScene(scene);
//            primaryStage.show();
            
            AdapterClient adapterClient = new AdapterClient();
			Stage primaryStage = new Stage();
			adapterClient.start(primaryStage);
           
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	
	@FXML
	public void onSafeComposite(ActionEvent av) throws Exception {
        
        try {
        	
        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/ConsistentCompositeUI.fxml"));
        	Scene scene = new Scene(parent);
            Stage primaryStage = new Stage();
            primaryStage.setScene(scene);
            primaryStage.show();
           
        } catch (Exception e) {
            e.printStackTrace();
        }
        
	}
	
	@FXML
	public void onConsistentComposite(ActionEvent av) throws Exception {
        
        try {
        	
        	Parent parent = FXMLLoader.load(getClass().getClassLoader().getResource("cn/edu/scau/cmi/zhuangjunsheng/comprehensiveExperiment/ConsistentCompositeUI.fxml"));
        	Scene scene = new Scene(parent);
            Stage primaryStage = new Stage();
            primaryStage.setScene(scene);
            primaryStage.show();
           
        } catch (Exception e) {
            e.printStackTrace();
        }
        
	}
	


}
